{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8a142faa",
   "metadata": {},
   "source": [
    "# 第一题\n",
    "+ **要求**：创建一个从0到9的一维数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "60befa4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "np.arange(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "18d57c83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([i for i in range(10)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cd7da6aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linspace(0,9,10)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f62e888",
   "metadata": {},
   "source": [
    "# 第二题\n",
    "+ **要求**：将arr中的奇数都修改成1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "4488962a",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr= np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n",
    "arr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "42c8d662",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 1, 4, 1, 6, 1, 8, 1])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr[arr%2==1]=1\n",
    "arr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "025a83d6",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 1, 4, 1, 6, 1, 8, 1])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for i,item in enumerate(arr):\n",
    "#     if item %2 ==1:\n",
    "    if (item//2)*2 !=item:\n",
    "        arr[i]=1\n",
    "arr"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89a2c010",
   "metadata": {},
   "source": [
    "# 第三题\n",
    "+ **要求**：将下面两个数组按照行进行合并,然后按列均等拆分成三个数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "64d2de58",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr1=np.array([[1,2,3],[1,2,3]])\n",
    "arr2=np.random.randint(0,10,(3,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "3f090190",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [1, 2, 3]])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "1a20455e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[6, 7, 7],\n",
       "       [3, 6, 4],\n",
       "       [8, 0, 7]])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "d5bf43ac",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [1, 2, 3],\n",
       "       [6, 7, 7],\n",
       "       [3, 6, 4],\n",
       "       [8, 0, 7]])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.vstack((arr1,arr2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "f602c684",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr3=np.concatenate((arr1,arr2),axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "3617df9e",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[1],\n",
       "        [1],\n",
       "        [6],\n",
       "        [3],\n",
       "        [8]]),\n",
       " array([[2],\n",
       "        [2],\n",
       "        [7],\n",
       "        [6],\n",
       "        [0]]),\n",
       " array([[3],\n",
       "        [3],\n",
       "        [7],\n",
       "        [4],\n",
       "        [7]])]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.split(arr3,3,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "14f6d034",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[1],\n",
       "        [1],\n",
       "        [6],\n",
       "        [3],\n",
       "        [8]]),\n",
       " array([[2],\n",
       "        [2],\n",
       "        [7],\n",
       "        [6],\n",
       "        [0]]),\n",
       " array([[3],\n",
       "        [3],\n",
       "        [7],\n",
       "        [4],\n",
       "        [7]])]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.hsplit(arr3,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a8a62ab",
   "metadata": {},
   "source": [
    "# 第四题\n",
    "+ **要求**：创建一个10x10的随机浮点数矩阵，并找到最大值和最小值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "30a04fb6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.993509275042626, 0.015167788478639532)"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr4=np.random.random((10,10))\n",
    "arr4.max(),arr4.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "1ae22c6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.33004291, 0.70411967, 0.85494436, 0.84528337, 0.72143812,\n",
       "        0.68292418, 0.63594958, 0.66754171, 0.40415129, 0.30951739],\n",
       "       [0.3308309 , 0.97531819, 0.49696873, 0.59454158, 0.43414308,\n",
       "        0.34621157, 0.47378841, 0.77766403, 0.64223817, 0.22010805],\n",
       "       [0.57759105, 0.41887579, 0.32570248, 0.72981238, 0.05869306,\n",
       "        0.53504568, 0.83180617, 0.89075995, 0.98994351, 0.96555379],\n",
       "       [0.86229405, 0.23127259, 0.59125685, 0.85932546, 0.44552806,\n",
       "        0.6047619 , 0.00274718, 0.10930031, 0.58659788, 0.69281874],\n",
       "       [0.58123734, 0.15039978, 0.94928274, 0.16587519, 0.73842645,\n",
       "        0.84164351, 0.78079063, 0.92854363, 0.03814058, 0.23969111],\n",
       "       [0.32589185, 0.17081408, 0.22155005, 0.16295029, 0.93623009,\n",
       "        0.89967223, 0.80657926, 0.92811796, 0.66279259, 0.56153516],\n",
       "       [0.87650462, 0.56391876, 0.56462971, 0.95170803, 0.51539831,\n",
       "        0.28657517, 0.33618721, 0.0267825 , 0.8472713 , 0.49578383],\n",
       "       [0.87958554, 0.80230382, 0.22034445, 0.59016042, 0.31869211,\n",
       "        0.42434255, 0.60463936, 0.66580609, 0.35843793, 0.35566678],\n",
       "       [0.10073596, 0.59789167, 0.64858441, 0.74290743, 0.99015586,\n",
       "        0.57402209, 0.6608518 , 0.45522708, 0.40956564, 0.63959083],\n",
       "       [0.59951815, 0.1382484 , 0.8067921 , 0.3899796 , 0.45371627,\n",
       "        0.065134  , 0.54931822, 0.36179971, 0.59380209, 0.37946668]])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr4"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "New_jd",
   "language": "python",
   "name": "venv"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
